package top.bulk.intemasking.annotation;

import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import top.bulk.intemasking.enums.SensitiveTypeEnum;
import top.bulk.intemasking.serializer.SensitiveSerializer;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 敏感词脱敏注解
 *
 * @author 散装java
 * @date 2024-07-15
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@JacksonAnnotationsInside
@JsonSerialize(using = SensitiveSerializer.class)
public @interface SensitiveMasking {
    /**
     * 脱敏类型
     */
    SensitiveTypeEnum type() default SensitiveTypeEnum.DEFAULT;

    /**
     * 脱敏起始位置
     */
    int startInclude() default 0;

    /**
     * 脱敏结束位置
     */
    int endExclude() default 0;

    /**
     * 脱敏替换字符
     */
    char replacedChar() default '*';

}
